#include <iostream>
using namespace std;

int partition(int (&arr)[30001], int begin, int end){
	int i = begin;
	int j = end;
	int temp = arr[begin];
	while(i < j){
		while( i < j && arr[j] >= temp) j--;
		if(i<j) arr[i] = arr[j];
		while( i < j && arr[i] <= temp) i++;
		if(i < j)arr[j] = arr[i];
	}
	arr[i] = temp;
	return i;
}

void quickSort(int (&arr)[30001], int begin, int end){
	if(begin >= end) return;
	int p = partition(arr,begin, end);
	quickSort(arr, begin, p - 1);
	quickSort(arr, p + 1, end);
}

int main(){
	int maxW;
	cin >> maxW;
	int itemNum;
	cin >> itemNum;
	int arr[30001];
	for(int i = 1; i <= itemNum; i++)
		cin >> arr[i];
	int count = 0; //how many item have been selected
	int result = 0; //result: how many group have been selected.
	quickSort(arr, 1, itemNum);
	int i = count + 1;
	int j = itemNum;
	while(count < itemNum){
		if(arr[j] + arr[i] > maxW){
			arr[j] = -1;
			result++;
			count++;
			j--;
		} else {
			arr[i] = -1;
			arr[j] = -1;
			result++;
			count += 2;
			i++;
			j--;
		}
	}
	cout << result << endl;
}
